/**
 * Copyright 2011 Joe Choi, All rights reserved.
 */
package tao.data.structure.tree;

import tao.data.structure.tree.Tree;
import tao.pattern.observer.BaseObservable;

/**
 * The basic implementation of Traversal interface
 * 
 * @author Joe Choi
 */
abstract class AbstractTraversal<V> 
	extends BaseObservable<Traversal.Event<V>> implements Traversal<V> {
	public AbstractTraversal(Tree<V> tree) {
		this.tree = tree;
	}

	@Override
	public void start() {
		traverse(tree);
	}
		
	protected abstract void traverse(Tree<V> t);

	private Tree<V> tree;
	
	/**
	 * The basic implementation of Factory interface
	 */
	static abstract class AbstractFactory<V> implements Traversal.Factory<V> {
		public AbstractFactory(Tree<V> tree) {
			this.tree = tree;
		}
		
		protected Tree<V> getTree() {
			return(tree);
		}
		
		private Tree<V> tree;
	}	
}